import {
  ApiProperty,
  IntersectionType,
  OmitType,
  PartialType,
  PickType,
} from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';
import { FindListDto } from 'src/modules/find-list.dto';

export class BillingManagementDto {
  @IsInt()
  @ApiProperty({ type: Number, description: 'id' })
  readonly id: number;

  @ApiProperty({ type: Number, description: '金额', default: 0 })
  public money: number;

  @ApiProperty({ type: Date, description: '日期' })
  public date_time: Date;

  @IsString()
  @ApiProperty({ type: String, description: '类型' })
  public type: string;

  @ApiProperty({
    type: String,
    description: '备注',
  })
  public remark: string;

  @ApiProperty({ type: Date, description: '创建时间', default: null })
  readonly created_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '创建人',
    default: null,
  })
  readonly created_by: string;

  @ApiProperty({ type: Date, description: '更新时间', default: null })
  readonly updated_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '更新人',
    default: null,
  })
  readonly updated_by: string;
}

export class FindBillingManagementDto {
  @ApiProperty({ type: Array, description: '日期' })
  public time: any;

  @IsString()
  @ApiProperty({ type: String, description: '类型' })
  public type: string;
}

export class FindBillingManagementListDto extends IntersectionType(
  PartialType(FindListDto),
  PartialType(FindBillingManagementDto),
) {}
export class BillingManagementObj extends PickType(BillingManagementDto, [
  'id',
] as const) {}

export class CreateBillingManagementDto extends PartialType(
  OmitType(BillingManagementDto, ['id', 'created_date', 'updated_date']),
) {}

export class UpdateBillingManagementDto extends PartialType(
  OmitType(BillingManagementDto, ['created_date', 'updated_date']),
) {}
